package com.likeycy.my;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: MyStack1
 * @Description: MyStack自定义栈优化第一版
 * @Author: sodagreen
 * @Date: 2021/3/4 16:16
 * @Version: 1.0
 */
public class MyStack1<E> {
    private List<E> list = new ArrayList<E>();


    public int size() {
        return list.size();
    }

    public boolean isEmpty() {
        return list.isEmpty();
    }

    public void push(E element) {
        list.add(element);
    }

    public E pop() {
        return list.remove(size() -1);
    }

    public E top() {
        return list.get(size() -1);
    }

}
